//
//  ViewController.m
//  调用系统原生分享
//
//  Created by zxy on 2018/11/13.
//  Copyright © 2018年 zxy. All rights reserved.
//

#import "ViewController.h"
#import <Social/Social.h>
#import "customActivity.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)share:(UIButton *)sender {
    
/*
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToFacebook     NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToTwitter      NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToWeibo        NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;    // SinaWeibo
    UIKIT_EXTERN UIActivityType const UIActivityTypeMessage            NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeMail               NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePrint              NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeCopyToPasteboard   NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAssignToContact    NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeSaveToCameraRoll   NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAddToReadingList   NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToFlickr       NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToVimeo        NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypePostToTencentWeibo NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeAirDrop            NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeOpenInIBooks       NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED;
    UIKIT_EXTERN UIActivityType const UIActivityTypeMarkupAsPDF        NS_AVAILABLE_IOS(11_0) __TVOS_PROHIBITED;
    */
    
   
    
    /*分享到微信不支持纯文本*/
    NSString *shareText = @"要分享的内容";
    UIImage *image = [UIImage imageNamed:@"1.png"];
    NSURL *url = [NSURL URLWithString:@"https://www.taobao.com"];
    NSArray *activityItems = @[shareText,image,url];
//    
//    
     customActivity * wxHYActivit = [[customActivity alloc] initWithTitie:@"微信好友" withActivityImage:[UIImage imageNamed:@"Share_ActionSheet_Friends"] withUrl:url withType:@"customActivity" withShareContext:activityItems];
//
    customActivity * qqHYActivit = [[customActivity alloc] initWithTitie:@"QQ空间" withActivityImage:[UIImage imageNamed:@"Share_ActionSheet_Qzone"] withUrl:url withType:@"customActivity" withShareContext:activityItems];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:@[wxHYActivit,qqHYActivit]];
//    //排除特定类型
    activityVC.excludedActivityTypes = @[UIActivityTypeMail,UIActivityTypePrint,UIActivityTypeCopyToPasteboard,UIActivityTypeMessage,
                                        UIActivityTypeAssignToContact,UIActivityTypeAddToReadingList,UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,UIActivityTypeAirDrop,UIActivityTypeOpenInIBooks,UIActivityTypeMarkupAsPDF,UIActivityTypePostToTwitter];
    [self presentViewController:activityVC animated:YES completion:nil];
//
//    //选中活动列表类型
//    [activityVC setCompletionWithItemsHandler:^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
//        if(completed){
//            NSLog(@"分享成功");
//        }else{
//            NSLog(@"分享失败");
//        }
//    }];
}

@end
